package main

import (
	"books/models"

	"github.com/wailsapp/wails/v2/pkg/runtime"
)

func (a *App) GetCategories() []models.Category {
	categories, err := models.GetCategories()
	if err != nil {
		runtime.EventsEmit(a.ctx, "error", err.Error())

		return nil
	}

	return categories
}

func (a *App) CreateCategory(name string) error {
	t := models.Category{
		Name: name,
	}

	return t.CreateCategory()
}
